<!--<template>
  <div>油心分专项分期Largeapprs</div>
 </template> -->
<template>
    <div
        class="cash-contnair"
        v-loading="isLoading"
        element-loading-background="rgba(250, 250, 250, 0.7)"
    >
        <!-- 油心分专项分期 -->
        <!-- <el-card
      shadow="never"
      v-loading="isLoading"
      element-loading-background="rgba(250, 250, 250, 0.7)"
    >
      <div slot="headerss" class="clearfix">
        <span>油心分专项分期</span>
        <el-button style="float: right; padding: 3px 20px;" type="text">关 闭</el-button>
        </div>-->
        <cardComponent pageTitle="油心分专项分期">
            <template slot="cardBody">
                <el-form ref="cashFormRef" :model="cashForm" label-width="220px" size="small">
                    <el-row>
                        <el-col :span="10">
                            <el-form-item label="账户类别 : ">
                                <el-input disabled v-model="cashForm.CATEGORY" style="width: 100%;"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col :span="12">
                            <el-form-item label="油心分专项分期额度 : ">
                                <el-input
                                    disabled
                                    v-model="cashForm.LMPLIMIT_1"
                                    style="width: 80%;"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="10">
                            <el-form-item label="主卡卡号 : ">
                                <el-input disabled v-model="cashForm.CARDNBR" style="width: 100%;"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="油心分专项分期已用额度 : ">
                                <el-input
                                    disabled
                                    v-model="cashForm.LIMIT_AVAL"
                                    style="width: 80%;"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="10">
                            <el-form-item label="签约借记卡卡号 : ">
                                <el-input
                                    disabled
                                    v-model="cashForm.CARDNAME_1"
                                    style="width: 100%;"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="油心分专项分期可用额度 : ">
                                <el-input
                                    class="t-red"
                                    disabled
                                    v-model="cashForm.LMPAVAL"
                                    style="width: 80%;"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 试算列表 -->
                    <el-table
                        :data="tableDataLarge"
                        style="width: 100%;"
                        size="small"
                        stripe
                        border
                        class="heard-bg business_table"
                    >
                        <el-table-column label="费用试算表">
                            <el-table-column prop="AMT" label="分期金额" min-width="160">
                                <template slot-scope="scope">
                                    <el-input
                                        v-model="scope.row.AMT"
                                        @blur="onChanger"
                                        maxlength="7"
                                        size="small"
                                        placeholder="请输入分期金额"
                                    />
                                </template>
                            </el-table-column>
                            <el-table-column prop="NBRMTHS1" label="分期期数" min-width="160">
                                <template slot-scope="scope">
                                    <el-select
                                        v-model="scope.row.NBRMTHS1"
                                        size="small"
                                        placeholder="选择分期数"
                                        @change="onChanger"
                                    >
                                        <!-- <el-option label="3期 -- 0.021" value="003"></el-option>
                  <el-option label="6期 -- 0.036" value="006"></el-option>
                  <el-option label="9期 -- 0.054" value="009"></el-option>
                  <el-option label="12期 -- 0.072" value="012"></el-option>
                  <el-option label="18期 -- 0.108" value="018"></el-option>
                                        <el-option label="24期 -- 0.144" value="024"></el-option>-->
                                        <el-option
                                            v-for="(item, index) in instalmentNoList"
                                            :key="index"
                                            :label="item.label"
                                            :value="item.nbrMths"
                                        ></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column prop="CHARGETYPE" label="手续费收取方式" min-width="160">
                                <template slot-scope="scope">
                                    <el-select
                                        v-model="scope.row.CHARGETYPE"
                                        :disabled="isThree"
                                        style="width: 100%;"
                                        placeholder="手续费收取方式"
                                        @change="onChanger"
                                    >
                                        <el-option label="一次性收取" value="0"></el-option>
                                        <el-option label="分期收取" value="1"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column prop="OUTFLAG" label="转入银行卡类型" min-width="160">
                                <template slot-scope="scope">
                                    <el-select
                                        v-model="scope.row.OUTFLAG"
                                        style="width: 100%;"
                                        placeholder="选择银行卡类型"
                                        @change="onChanger"
                                    >
                                        <el-option label="无" value></el-option>
                                        <el-option label="本行" value="C"></el-option>
                                        <el-option label="他行" value="X"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column prop="CORPUS" label="首期还款额" min-width="100"></el-table-column>
                            <el-table-column prop="REMONTHFEE" label="月还款额" min-width="100"></el-table-column>
                            <el-table-column prop="ALLMONTHSFEE" label="分期手续费" min-width="100"></el-table-column>
                            <el-table-column prop="ALLCOUNTFEE" label="本金+手续费总额" min-width="130"></el-table-column>
                        </el-table-column>
                    </el-table>
                </el-form>
                <div class="footer">
                    <el-button type="primary" size="small" plain @click="onEditInfor">修改信息</el-button>
                    <el-button type="primary" size="small" @click="onSubmit">申 请</el-button>
                    <!-- <el-button>关 闭</el-button> -->
                </div>
                <!-- </el-card> -->

                <!-- 修改信息窗口 -->
                <!-- <el-dialog v-drag
      title="油心分专项分期资料修改"
      :visible.sync="showEdit"
      append-to-body
      @close="closeEdit"
      top="25vh"
      center
      width="600px"
    >
      <el-form
        :model="cashEditForm"
        :rules="cashEditFormRules"
        ref="cashEditFormRef"
        label-width="250px"
        size="small"
      >
        <el-form-item label="账户类别 : ">
          <el-input class="b-0" readonly v-model="cashEditForm.CATEGORY" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="主卡卡号 : ">
          <el-input class="b-0" readonly v-model="cashEditForm.CARDNBR" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="申请转入的银行卡号 : " prop="CARDNAME">
          <el-input v-model="cashEditForm.CARDNAME" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="申请转入的银行卡持卡人姓名 : ">
          <el-input v-model="cashEditForm.CUSTRNAME" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="申请转入的银行行号 : ">
          <el-input v-model="cashEditForm.BANKNO" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="申请转入的银行卡银行名称 : ">
          <el-select
            v-model="cashEditForm.CARDBANK"
            placeholder="请选择转入的银行卡银行名称"
            style="width: 250px;"
          >
            <el-option label="空" value="shanghai"></el-option>
            <el-option label="中国银行总行" value="beijing"></el-option>
            <el-option label="中国工商银行" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="申请转入银行卡类型 : ">
          <el-select v-model="cashEditForm.OUTFLAG" placeholder="请选择转入银行卡类型" style="width: 250px;">
            <el-option label="无" value></el-option>
            <el-option label="本行" value="C"></el-option>
            <el-option label="他行" value="X"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showEdit = false">取 消</el-button>
        <el-button type="primary" size="small" @click="setEditCash"size="small" icon="el-icon-circle-check" >确定</el-button>
      </div>
                </el-dialog>-->

                <!-- 申请成功返回提示 -->
                <ConfirmWindow
                    v-if="showApplydaily"
                    @isShow="close"
                    :dataList="ApplyCashForm"
                    :title="'油心分专项分期申请成功, 请勿重复申请! '"
                />
            </template>
        </cardComponent>
    </div>
</template>

<script>
import { mapState } from 'vuex';
import cardComponent from '@/components/cardComponent/cardComponent.vue';
import ConfirmWindow from '@/components/ConfirmWindow/ConfirmWindow.vue';
import {
    getInstalmentList, closePage, itoStr, getDictMappingValue,
} from '@/utils/Common';
import { get_4xxx, get_3xxx, get_FQxx } from '@/apis/getAPIClass';
import { setNumber, ChangePage, tbBudgetRequisi } from '@/utils/Object';

export default {
    data() {
        return {
            cashForm: {
                CATEGORY: '',
                LMPLIMIT: '',
                CARDNBR: '',
                CATEGORY: '',
                LIMIT_AVAL: '',
                CARDNAME: '',
                LMPAVAL: '',
            },
            ApplyCashForm: [],
            cashEditForm: {
                CATEGORY: '',
                CARDNBR: '',
                CUSTRNAME: '',
                CARDNAME: '',
                BANKNO: '',
                OUTFLAG: '',
                CARDBANK: '',
            },
            tableDataLarge: [
                {
                    AMT: '',
                    NBRMTHS1: undefined,
                    CHARGETYPE: '0',
                    OUTFLAG: undefined,
                    CORPUS: '' || 0,
                    REMONTHFEE: '' || 0,
                    ALLMONTHSFEE: '' || 0,
                    ALLCOUNTFEE: '' || 0,
                },
            ],
            instalmentNoList: [],
            // cashEditFormRules: {
            //   CARDNAME: [{ validator: {}, trigger: "blur" }]
            // },
            showTrial: false,
            showEdit: false,
            isLoading: false,
            timeID: '',
            isDisble: true,
            isThree: true,
            spbh: '', // 确定分期编号
            showApplydaily: false,
            productId: '',
        };
    },
    async mounted() {
        // 判断是否有当前权限
        await this.getExecuteFun();
        if (this.isLoading) return false;

        // 获取账户类别
        const MY_CATEGORY = await getDictMappingValue('CATE', this.cardInfo_3004.CATEGORY, this) || this.cardInfo_3004.CATEGORY;
        this.cashForm.CATEGORY = MY_CATEGORY;

        this.onLoadOBJ();
    },
    name: 'largeapprs',
    components: {
        cardComponent,
        ConfirmWindow,
    },
    computed: {
        ...mapState({
            defaultParams: state => state.common.defaultParams, // 接口默认参数
            cardInfo_3004: state => state.common.cardInfo_3004,
            cardList_3601: state => state.common.cardList_3601,
            inlineParams: state => state.common.inlineParams,
            pinFlag: state => state.common.pinFlag, // 是否密码检查标志  // 卡系统交易请求报文
        }),
    },
    methods: {
        // 判断是否有当前权限
        async getExecuteFun() {
            this.isLoading = true;
            this.productId = itoStr(this.cardInfo_3004.PRODUCT, 4) || this.cardInfo_3004.PRODUCT;
            console.log(this.productId);
            if (this.productId !== '0012') {
                return this.$alert(
                    '该卡种不支持油心分专项分期！',
                    '接口提示',
                    { customClass: 'warning', type: 'warning', showClose: false },
                ).then(() => {
                    closePage(this.$route, this, 1);
                });
            } this.isLoading = false;
        },

        // 页面加载获取页面数据请求_3052_3112请求
        async onLoadOBJ() {
            this.instalmentNoList = await getInstalmentList('3001', this);
            //  console.log(this.instalmentNoList);
            //  const.log()
            this.cashForm.CARDNBR = this.cardInfo_3004.CARDNO;
            this.isLoading = true;
            // 3052 配置请求头
            const appBody_3052 = {
                CARDNBR: this.cashForm.CARDNBR || '', // 卡号,
                PINFLAG: this.pinFlag,
                INQOPT: 1,
            };
            // 3112 配置请求头
            const appBody_3112 = {
                CARDNBR: this.cardInfo_3004.CARDNO || '',
                PINFLAG: this.pinFlag,
            };
            // 3001 配置请求头
            const appBody_3001 = {
                CARDNO: this.cardInfo_3004.CARDNO || '',
                PINFLAG: this.pinFlag,
            };
            // 发送_3052_3001_3112请求

            const result_3052 = await get_3xxx(
                '3052',
                '油心分专项分期',
                appBody_3052,
                this,
                false,
            );
            const result_3112 = await get_3xxx(
                '3112',
                '油心分专项分期',
                appBody_3112,
                this,
                false,
            );
            const result_3001 = await get_3xxx(
                '3001',
                '油心分专项分期',
                appBody_3001,
                this,
            );
            // console.log(result_3052, result_3001, result_3112);
            if (!result_3052 || !result_3001 || !result_3112) return false;

            this.cashForm.CARDNAME_1 = result_3052.body.appBody.CARDNAME;
            this.cashForm.CUSTRNAME = result_3052.body.appBody.CUSTRNAME;
            this.cashForm.BANKNO = result_3052.body.appBody.BANKNO;

            this.cashForm.CALIMIT = result_3001.body.appBody.CALIMIT;
            this.cashForm.CALAVAL = result_3001.body.appBody.CALAVAL;

            this.cashForm.LMPLIMIT_1 = result_3001.body.appBody.LMPLIMIT; // 923920
            this.tableDataLarge[0].NBRMTHS1 = '3';
            this.tableDataLarge[0].CHARGETYPE = '0';
            this.cashForm.LMPLIMIT = result_3112.body.appBody.LBMPAVAIL; // 大额现金分期可用额度  876900

            // 油心分专项分期已用额度
            // 大额分期可用限额 // 886720       // 大额分期付款可用额度 LMPAVAIL // 撤销后 923820   // 申请后 923620
            if (
                result_3112.body.appBody.MPLLIMAVL > result_3001.body.appBody.LMPAVAIL
            ) {
                // 已用额度 = 大额分期付款额度   -  大额分期付款可用额度
                this.cashForm.LIMIT_AVAL = // 923920 - 923820
                    (
                        result_3001.body.appBody.LMPLIMIT - result_3001.body.appBody.LMPAVAIL
                    ).toFixed(2);
                // 可用额度   ===  撤销后 923820   // 申请后 923620
                this.cashForm.LMPAVAL = result_3001.body.appBody.LMPAVAIL; // undfind // 大额分期付款可用额度 LMPAVAIL // 876900

                console.log(
                    result_3001.body.appBody.LMPLIMIT,
                    result_3001.body.appBody.LMPAVAIL,
                    '1',
                );
            } else {
                // 已用额度
                this.cashForm.LIMIT_AVAL = // 923920  - 886720  === 37200
                    (
                        result_3001.body.appBody.LMPLIMIT - result_3112.body.appBody.MPLLIMAVL
                    ).toFixed(2);
                // 可用额度    ===== 886720
                this.cashForm.LMPAVAL = result_3112.body.appBody.MPLLIMAVL; // 0

                console.log(
                    result_3001.body.appBody.LMPLIMIT,
                    result_3112.body.appBody.MPLLIMAVL,
                    '2',
                );
            }
            // console.log(this.cashForm);
            this.isLoading = false;
        },
        // 修改信息 跳转到修改页面
        onEditInfor() {
            // this.cashEditForm.CATEGORY = this.cashForm.CATEGORY;
            // this.cashEditForm.CARDNBR = this.cashForm.CARDNBR;
            // this.cashEditForm.CARDNAME = this.cashForm.CARDNAME;
            // this.cashEditForm.CUSTRNAME = this.cashForm.CUSTRNAME;
            // this.cashEditForm.BANKNO = this.cashForm.BANKNO;
            this.$router.push('/cashInstalment/cashInstUpdate');
        },
        // 4098 試算請求
        onChanger() {
            if (this.tableDataLarge[0].NBRMTHS1 == '3') {
                this.tableDataLarge[0].CHARGETYPE = '0';
                this.isThree = true;
            } else {
                this.isThree = false;
            }
            if (!this.tableDataLarge[0].AMT || !this.tableDataLarge[0].NBRMTHS1) return false;
            // console.log(1111)
            this.apply();
            // 判断是他行还是本行
            // if (this.tableDataLarge[0].OUTFLAG === "C") {
            //   // 请求行内接口
            //   return this.$alert(
            //           "需要连接到行内接口 FQ03 申请",
            //           "接口提示
            //           { confirmButtonText: "确定" }
            //         );
            //   this.isLoading = false;
            // }this.tableDataLarge[0].AMT, 11
            this.get_4098(this.spbh, this.tableDataLarge[0].AMT);
        },
        async get_4098(PRODID, AMT, OPERTP = 3, PATTERN = 3) {
            this.isLoading = true;
            // 4098 配置请求头
            const appBody_4098 = {
                CARDNBR: this.cashForm.CARDNBR,
                OPERTP, // 操作类型0：查询 1：申请 2：当日撤销3：试算
                PATTERN, // 操作类型为1和2时必填1：现金贷款类大额分期（出文件放款）2：现金贷款类大额分期（实时放款到主账户）3:现金贷款类大额分期（日终请款）4:现金贷款类大额分期（日终请款、出交易明细流水）
                PINFLAG: this.pinFlag,
                MPAMT: AMT * 100,
                MONTHS: this.tableDataLarge[0].NBRMTHS1, // 分期期数
                PRODID, // 分期商品编号
                FORCECHK: 0,
                CHKFLAG: 0,
                // CURRNUM: 156
            };
            // console.log(appBody_4098, "_4098");
            const result_4098 = await get_4xxx(
                '4098',
                '油心分专项分期',
                appBody_4098,
                this,
                false,
            );
            // console.log(result_4098, "_4098");
            if (!result_4098) return false;
            if (OPERTP == 1) {
                this.showApplydaily = true;
                const res = result_4098.body.appBody;
                // this.ApplyCashForm = res_4073.body.appBody;
                this.ApplyCashForm = [
                    { keys: '商品编号 : ', values: res.PRODID },
                    { keys: '分期金额 : ', values: res.MPAMT },
                    { keys: '分期期数 : ', values: res.MONTHS },
                    { keys: '每月还款金额 : ', values: res.MPINSTL },
                    { keys: '手续费 : ', values: res.FEEAMT },
                ];
                // 发送新增分期申请记录 tbBudgetRequisi
                const tbBudgetRequisiData = JSON.parse(JSON.stringify(tbBudgetRequisi));
                tbBudgetRequisiData.agentid = this.defaultParams.body.appHead.opeNo;
                tbBudgetRequisiData.allcountfee = res.FEEAMT;
                tbBudgetRequisiData.banknum = this.defaultParams.body.appHead.bnknbr;
                tbBudgetRequisiData.budgettype = res.OPERTP;
                tbBudgetRequisiData.custid = this.cardInfo_3004.CUSTID || '无';
                tbBudgetRequisiData.custname = this.cardInfo_3004.NAME;
                tbBudgetRequisiData.custno = res.CARDNBR;
                tbBudgetRequisiData.instalamt = res.MPAMT;
                // tbBudgetRequisiData.jzrate = res.FEERATE
                tbBudgetRequisiData.planno = '无';
                tbBudgetRequisiData.retcode = '000000';
                tbBudgetRequisiData.monthnbr = res.MONTHS;

                console.log(tbBudgetRequisiData);
                try {
                    const resss = await this.$post.businessStatistics.addTbBudgetRe(
                        tbBudgetRequisiData,
                    );
                    console.log(resss);
                } catch (error) {
                    console.warn(error);
                }

                return false;
                // return this.$alert(`油心分专项分期申请成功`, "油心分专项分期提示！", {
                //   confirmButtonText: "确定",
                //   center: true,
                //   type: "success",
                //   showClose: false
                // });
            }
            // 成功之后当前显示
            this.isDisble = false;
            // let feeInstl = result_4098.body.appBody.MPINSTL*1;		//月手续费
            const instalAmt = result_4098.body.appBody.MPINSTL * 1; // 月还款额
            let feeAmt = result_4098.body.appBody.FEEAMT * 1; // 总手续费
            const feePcnt = result_4098.body.appBody.FEEPCNT * 1; // 利率
            const feeFlag = this.tableDataLarge[0].CHARGETYPE; // 0：一次性收取 1：分期收取
            const mp_irr = result_4098.body.appBody.MPIRR * 1; // 年化利率

            const amount = this.tableDataLarge[0].AMT * 1;
            const mon = parseInt(this.tableDataLarge[0].NBRMTHS1);
            // console.log(instalAmt, feeAmt, feePcnt, feeFlag, mp_irr, amount, mon);
            // 首期还款额 = 本金 / 期数 + 总手续费
            let firstAmts = amount / mon + feeAmt;

            // 总还款额 = 总手续费 + 本金
            let allcountfee = feeAmt + amount;

            // 本金 = 本金 / 期数
            let corpus = 0;
            corpus = amount / mon;
            if (feeFlag == 0) {
                feeAmt *= 0.75;
                firstAmts = (firstAmts - corpus) * 0.75 + corpus;
                allcountfee -= feeAmt / 3;
            }
            // 月还款额 = 本金 + 月手续费
            // this.tableDataLarge[0].instalAmts = corpus + feeInstl;
            this.tableDataLarge[0].ALLCOUNTFEE = (allcountfee * 1).toFixed(2);
            // 首期还款额 = 本金 / 期数 + 总手续费
            this.tableDataLarge[0].CORPUS = firstAmts.toFixed(2);
            this.tableDataLarge[0].ALLMONTHSFEE = feeAmt.toFixed(2);
            this.tableDataLarge[0].REMONTHFEE = instalAmt.toFixed(2);

            this.isLoading = false;
        },
        // 设置分期编号
        apply() {
            const mon = this.tableDataLarge[0].NBRMTHS1;

            const tm = mon; // .split(",");

            let flag;
            const chargeType = this.tableDataLarge[0].CHARGETYPE; // 手续费收取方式
            const out_flag = this.tableDataLarge[0].OUTFLAG; // 转入银行卡类型
            if (out_flag == 'X') {
                if (chargeType == '0') {
                    // 一次性收取
                    if (tm == '3') {
                        flag = '';
                    } else {
                        flag = 'Y';
                    }
                } else if (tm == '3') {
                    flag = 'F';
                } else {
                    flag = '';
                }
            } else if (chargeType == '0') {
                // 一次性收取
                if (tm == '3') {
                    flag = 'K';
                } else {
                    flag = 'YK';
                }
            } else if (tm == '3') {
                flag = 'FK';
            } else {
                flag = 'K';
            }

            if (out_flag == 'X') {
                if (chargeType == '0') {
                    // 一次性收取
                    if (tm == '3') {
                        this.spbh = `DEFQ0000${tm}${flag}`; // 确定分期编号
                    } else {
                        this.spbh = `DEFQ000${tm}${flag}`; // 确定分期编号
                    }
                } else {
                    // 分期收取
                    if (tm == '6' || tm == '9') {
                        this.spbh = `DEFQ0000${tm}${flag}`; // 确定分期编号
                    } else {
                        this.spbh = `DEFQ000${tm}${flag}`; // 确定分期编号
                    }
                }
            } else {
                this.spbh = `DEFQ000${tm}${flag}`; // 确定分期编号
            }
        },
        // 修改有信分资料 4075 请求
        // async setEditCash() {
        //   this.isLoading = true;
        //   // 4075 配置请求头
        //   const appBody_4075 = {
        //     CARDNBR: this.cashForm.CARDNBR || "", // 卡号,
        //     PINFLAG: 0,
        //     OPERTP: 0,
        //     OUTCARDNBR: this.cashEditForm.CARDNAME, // 申请转入的银行卡卡号
        //     OUTBANKNAME: this.cashEditForm.CARDBANK, // 申请转入的银行卡银行名称
        //     OUTEXP: this.cashEditForm.CARDNAME, // 申请转入的银行卡卡片有效期
        //     OUTFLAG: this.cashEditForm.OUTFLAG, // 申请转移的银行卡类型
        //     OUTBANK: this.cashEditForm.BANKNO, // 申请转入的银行卡银行行号
        //     CALNAME: this.cashEditForm.CUSTRNAME, // 申请转入的银行卡持卡人姓名 选填
        //     MPDRTYN: 1,
        //     BTYPE: 0
        //   };
        //   const defaultParams_4075 = JSON.parse(JSON.stringify(this.defaultParams));
        //   defaultParams_4075.body.appHead.tranCode = "4075";
        //   defaultParams_4075.body.appBody = appBody_4075;
        //   // 发送_4075请求
        //   try {
        //     const _4075 = await this.$post.common.transPort(
        //       defaultParams_4075
        //     );
        //     console.log(_4075);
        //     if (_4075.status === 200) {
        //       const result_4075 = JSON.parse(_4075.data.jsonRes);
        //       console.log(result_4075);
        //       if (result_4075.sysHead.rspCd === "000000") {
        //         this.$message.success("现金贷数据修改成功");
        //       } else {
        //         this.isLoading = false;
        //         return this.$alert(
        //           `错误代码：${result_4075.sysHead.rspCd}，错误信息：${result_4075.sysHead.rspMsg}`,
        //           "现金贷数据修改失败！",
        //           { confirmButtonText: "确定", center: true, type: "warning " }
        //         );
        //       }
        //     }
        //     this.isLoading = false;
        //   } catch (error) {
        //     this.$message.error("获取数据失败");
        //     this.isLoading = false;
        //   }
        // },
        // 申请
        async onSubmit() {
            if (!this.tableDataLarge[0].AMT) return this.$message.warning('请输入分期金额');
            if (!this.tableDataLarge[0].NBRMTHS1) return this.$message.warning('请选择分期数');
            if (!this.tableDataLarge[0].OUTFLAG) return this.$message.warning('请选择转入银行卡类型');
            // if (
            //   !this.tableDataLarge[0].AMT ||
            //   !this.tableDataLarge[0].NBRMTHS1 ||
            //   !this.tableDataLarge[0].CHARGETYPE ||
            //   !this.tableDataLarge[0].OUTFLAG
            // )
            //   return false;
            this.apply();
            // 判断是他行还是本行
            if (this.tableDataLarge[0].OUTFLAG === 'C') {
                // 请求行内接口
                const appBody_FQ03 = {
                    SOURCE: 'AG', // 交易来源
                    CARDNBR: this.cashForm.CARDNBR,
                    PINFLAG: this.pinFlag,
                    OPERTP: 1,
                    PATTERN: 4,
                    PRODID: this.spbh,
                    MPAMT: this.tableDataLarge[0].AMT * 100,
                    // MPAMT: setNumber(this.tableDataLarge[0].AMT, 11), // 分期金额
                    NBRMTHS: setNumber(this.tableDataLarge[0].NBRMTHS1, 3, false), // 分期期数
                };
                // console.log(appBody_FQ03);
                // 发送_FQ03请求 //   数据存在 resultData.body.appBody
                const result_FQ03 = await get_FQxx(
                    'FQ03',
                    '按日贷申请',
                    appBody_FQ03,
                    this,
                );
                // console.log(result_FQ03);
                if (!result_FQ03) return false;

                this.isLoading = false;
                const res = result_FQ03.body.appBody;
                this.ApplyCashForm = [
                    { keys: '商品编号 : ', values: res.PRODID },
                    { keys: '分期金额 : ', values: res.MPAMT },
                    { keys: '分期期数 : ', values: res.MONTHS },
                    { keys: '每月还款金额 : ', values: res.MPINSTL },
                    { keys: '手续费 : ', values: res.FEEAMT },
                ];
                // 发送新增分期申请记录 tbBudgetRequisi
                const tbBudgetRequisiData = JSON.parse(JSON.stringify(tbBudgetRequisi));
                tbBudgetRequisiData.agentid = this.defaultParams.body.appHead.opeNo;
                tbBudgetRequisiData.allcountfee = res.FEEAMT;
                tbBudgetRequisiData.banknum = this.defaultParams.body.appHead.bnknbr;
                tbBudgetRequisiData.budgettype = res.OPERTP;
                tbBudgetRequisiData.custid = this.cardInfo_3004.CUSTID || '无';
                tbBudgetRequisiData.custname = this.cardInfo_3004.NAME;
                tbBudgetRequisiData.custno = res.CARDNBR;
                tbBudgetRequisiData.instalamt = res.MPAMT;
                // tbBudgetRequisiData.jzrate = res.FEERATE
                tbBudgetRequisiData.planno = '无';
                tbBudgetRequisiData.retcode = '000000';
                tbBudgetRequisiData.monthnbr = res.MONTHS;

                console.log(tbBudgetRequisiData);
                try {
                    const resss = await this.$post.businessStatistics.addTbBudgetRe(
                        tbBudgetRequisiData,
                    );
                    console.log(resss);
                } catch (error) {
                    console.warn(error);
                }

                return false;
                // return this.$alert(`油心分专项分期申请成功`, "油心分专项分期提示！", {
                //   confirmButtonText: "确定",
                //   center: true,
                //   type: "success",
                //   showClose: false
                // });
            }
            this.get_4098(this.spbh, this.tableDataLarge[0].AMT, 1, 3);

            // this.showApplydaily = true;
            // // this.ApplyCashForm = res_4073.body.appBody;
            // this.ApplyCashForm = [
            //   { keys: "账户类别 : ", values: this.sizeForm.CATEGORY },
            //   { keys: "提前还款手续费 : ", values: res_4073.body.appBody.ACCEFEE },
            //   { keys: "总期数 : ", values: res_4073.body.appBody.NBRMTHS },
            //   { keys: "提前还款罚息 : ", values: res_4073.body.appBody.ACCEINT },
            //   { keys: "已分摊期数 : ", values: res_4073.body.appBody.MTHSCNT },
            //   { keys: "提前还款金额 : ", values: res_4073.body.appBody.ACCEAMT }
            // ];

            this.tableDataLarge[0].AMT = '';
            this.tableDataLarge[0].OUTFLAG = '';
        },
        close(data) {
            this.showApplydaily = data;
            this.onLoadOBJ();
        },
    },
};
</script>

<style  scoped lang="scss">
.cash-contnair {
    /deep/.el-card__header {
        padding: 8px !important;
    }
    .form-row {
        width: 100%;
        margin: 0 auto;
        .el-form {
            margin: 0 auto;
            width: 1000px;
            .el-form-item__content {
                text-align: left;
            }
        }
        .el-select {
            width: 100%;
        }
        .sub-title {
            color: #909399;
        }
    }
    .el-col {
        text-align: center;
    }

    .footer {
        text-align: center;
        margin-top: 10px;
    }
}
</style>
